﻿Imports CodeMatrix.Context
Imports System.Linq

Partial Class Apps_DefaultPassword
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim StaffId = Request.QueryString("staff_code")
        Dim ctx As DataClassesDataContext = New DataClassesDataContext
        Try
            Dim updateStaff = ctx.staffs.Where(Function(s) StaffId.Equals(s.staff_code))

            Dim staf = (From s In ctx.staffs _
            Where s.staff_code = StaffId _
            Select s).First()

            If Not staf Is Nothing Then

                Dim strOld As String = Membership.GetUser(staf.staff_no).ResetPassword()
                Membership.GetUser(staf.staff_no).ChangePassword(strOld, "P@ssw0rd")

                staf.staff_status_login = 1
            End If

            ctx.SubmitChanges()

        Catch ex As Exception
            GenericHelper.ShowAlert(Me, ex)
        Finally
            ctx.Dispose()
        End Try

    End Sub
End Class
